package sample.business.frame;

import sample.data.PathInfo;

import java.io.File;

/**
 * Created by lilongfei on 2017/1/5.
 */
public class DirVo {

    protected static final String JAVA_DIRS = "src"+ File.separator+"main"+File.separator+"java";

    protected static final String RESOURCE_DIRS = "src"+File.separator+"main"+File.separator+"resources";

    protected static final String WEBAPP_DIRS = "src"+File.separator+"main"+File.separator+"webapp";

    protected static final String TEST_JAVA_DIRS = "src"+File.separator+"test"+File.separator+"java";

    protected static final String TEST_RESOURCES_DIRS = "src"+File.separator+"test"+File.separator+"resources";

    protected static final String CONTEXT_DIRS = "context";

    protected static final String WEB_INF_DIRS = "WEB-INF";

    private PathInfo pathInfo;

    public DirVo(PathInfo pathInfo){
        this.pathInfo = pathInfo;
    }

    public String getWorkDir(){
        return pathInfo.getWorkspace() + File.separator + pathInfo.getProjectName();
    }

    public String getHostDir(){
        return getJavaDir() + File.separator + pathInfo.getGroupId().replace(".",File.separator) + File.separator
                + pathInfo.getArtifactId() + File.separator;
    }

    public String getJavaDir(){
        return getWorkDir() + File.separator + JAVA_DIRS;
    }

    public String getResourceDir(){
        return getWorkDir() + File.separator + RESOURCE_DIRS;
    }

    public String getWebappDir(){
        return getWorkDir() + File.separator + WEBAPP_DIRS;
    }

    public String getTestJavaDir(){
        return getWorkDir() + File.separator + TEST_JAVA_DIRS;
    }

    public String getTestResourcesDir(){
        return getWorkDir() + File.separator + TEST_RESOURCES_DIRS;
    }

    public String getWorkName(){return pathInfo.getGroupId() + "." + pathInfo.getArtifactId();}

    public String getContextDir(){return getResourceDir() + File.separator + CONTEXT_DIRS;}

    public String getWebInfo(){
        return getWebappDir() + File.separator + WEB_INF_DIRS;
    }
}
